<!--班车点名情况统计表-->
<template>
    <div style="height: 100%;">
        <m-page-list
                ref="pageListRef"
                :option="option"
                :page="page"
                :total="total"
                :table-data="tableData"
                :table-loading="tableLoading"
                :page-loading="pageLoading"
                v-model:value="query"
                @h-btn-click="hBtnClick"
                @col-btn-click="colBtnClick"
                @search-data="searchData"
        >
            <template #import>
                <el-upload
                        ref="uploadRef"
                        class="upload-wrap"
                        action=""
                        accept=".xlsx,.xls"
                        :auto-upload="false"
                        :show-file-list="false"
                        :on-change="handleUploadChange"
                >
                    <el-button type="primary" >导入</el-button>
                </el-upload>
            </template>
        </m-page-list>


        <el-dialog class="dialog-wrap" v-model="detailShow" width="95%" :title="detailTitle" :close-on-click-modal="false" draggable align-center destroy-on-close>
            <shuttle-detail style="height: 90vh;" class="dtl-wrap" :data="shuttleData" @save="getDataList"></shuttle-detail>
        </el-dialog>
    </div>
</template>

<script setup>
  import {ref,reactive} from 'vue'
  import * as XLSX from 'xlsx'
  //组件
  import MPageList from '@/components/PageList'
  import ShuttleDetail from '../RollcallDailyShuttle/RollcallDailyShuttleDetail'
  //请求
  import {getRollCallDailyStatistics} from '@/request/api/basicData'
  import {refOpt} from "../const";
  import {crtTimeFtt} from "../../utils/utils";

  import {usePageList} from "../../composables/pageList";

  let opts = {
    // auth_id: '',
    getApi: getRollCallDailyStatistics,
    // idKey: 'row_id',
    // confirmCallback: publicPriorityPassengers,
    // deleteCallback: publicPriorityPassengers
  };

  let {option,page,total,tableLoading,pageLoading,tableData,query,dialogRef,dialogShow,dialogData,dialogOption,isAppend,
    newData,hBtnClick,colBtnClick,searchData,getDataList,dialogConfirm} = usePageList(opts);

  option.hLBtns = [];
  option.hRBtns = []
  option.colBtns = [{title: '查看',id: 'detail',type: 'primary',event: checkDetail},]
  option.conditions = [
    {label: '日期',field_id: 'shuttle_date', type: 'date',length: 'YYYY-MM-DD',col: 12},
    /*{...refOpt.rollcall_daily_shuttle_name,label: '点名班车',field_id: 'shuttle_name',col: 8,rewriteInput: true,
      refCols: [
        {prop: 'row_id',label: '行号' },
        {prop: 'shuttle_no',label: '点名班车号' },
        {prop: 'shuttle_name',label: '点名班车名' },
        {prop: 'direction',label: '方向' },
      ],valueKey: [{'shuttle_id': 'row_id'},],refParam: {shuttle_date: query.value.shuttle_date}
    },*/
    // {label: '班车类型',field_id: 'shuttle_type',type: 'picklist',options: [{name: '车站客运班车',id: '车站客运班车'},{name: '定制',id: '定制'},],col: 6},
    {...refOpt.shuttle_direction_name,field_id: 'direction',label: '方向',col:12, valueKey: [{'direction': 'shuttle_direction_name'}] ,rewriteInput: true},
  ];

  const today = crtTimeFtt(new Date(),'YYYY-MM-DD');
  query.value = {shuttle_date: today}   //默认当天查询条件

  option.cols = [
    {prop: 'shuttle_date', label: '日期',},
    {prop: 'shuttle_no', label: '点名班车号',},
    {prop: 'shuttle_name', label: '点名班车名',},
    {prop: 'direction',label: '方向' },
    {prop: 'state',label: '点名状态'},
    {prop: 'passenger_count',label: '乘客总人数' },
    {prop: 'should_check_count',label: '应出席人数' },
    {prop: 'check_count',label: '出席人数'},
    {prop: 'leave_count',label: '请假人数'},
    {prop: 'absent_count',label: '缺席人数'},
    {prop: 'not_check_count',label: '未点名人数'},
    {prop: 'rollcall_user_no',label: '点名人员号' },
    {prop: 'rollcall_user_name',label: '点名人员名' },
    {prop: 'rollcall_time',label: '最后点名时间' },
  ];


  /*---------------- 查看点名班车详情 ----------------*/
  let detailShow = ref(false),
    shuttleData = ref({}),
    detailTitle = ref('查看');
  function checkDetail(scope,id) {
    detailShow.value = true;
    let data = scope.row;
    data.row_id = data.shuttle_id;
    shuttleData.value = data;
    detailTitle.value = data.shuttle_name;
  }
</script>

<style scoped lang="less">
    .upload-wrap{
        display: inline-block;
        margin: 0 12px;
        vertical-align: bottom;

    }
</style>
